﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace Message_Board.Models
{
    public class User
    {
        [Display(Name = "用户账号")]
        [Required(ErrorMessage = "必填")]
        public int ID { get; set; }

        [Display(Name = "用户姓名")]
        public string Name { get; set; }

        [Display(Name = "用户密码")]
        [StringLength(15, MinimumLength = 3, ErrorMessage = "必须是[3,15]个字符")]
        [Required]
        public string Password { get; set; }

        [Display(Name = "邮箱")]
        [RegularExpression(@"([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+")]
        public string Email { get; set; }

        [Display(Name = "手机号码")]
        [RegularExpression(@"(130|135|139)\d{8}")]
        public string Telephone { get; set; }

        [Display(Name = "年龄")]
        [Range(1, 100)]
        public int Age { get; set; }

        [Display(Name = "性别")]
        public string Sex { get; set; }
    }

    public class UserDBContext : DbContext
    {
        public DbSet<User> Users { get; set; }
    }
}